package safety;

import model.FarmMachine;

import java.util.Date;

/**
 * 安全事件类
 * 封装需要处理的安全事件信息
 */
public class SafetyEvent {
    private String type;
    private String description;
    private String equipmentId;
    private long timestamp;
    private boolean resolved;

    public SafetyEvent(String type, String description, String equipmentId) {
        this.type = type;
        this.description = description;
        this.equipmentId = equipmentId;
        this.timestamp = System.currentTimeMillis();
        this.resolved = false;
    }

    public SafetyEvent(String type, String description, FarmMachine equipment) {
        this(type, description, equipment.getDeviceId());
    }

    public String getType() {
        return type;
    }

    public String getDescription() {
        return description;
    }

    public String getEquipmentId() {
        return equipmentId;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public boolean isResolved() {
        return resolved;
    }

    public void markAsResolved() {
        this.resolved = true;
        System.out.println("安全事件 " + this + " 已解决");
    }

    @Override
    public String toString() {
        return "安全事件: " + type +
                ", 描述: " + description +
                ", 设备ID: " + equipmentId +
                ", 时间: " + new Date(timestamp) +
                ", 状态: " + (resolved ? "已解决" : "未解决");
    }
}